package com.lw.leetcode.mode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author liw
 * @Date 2021/4/20 9:22
 * @Version 1.0
 */
public class Insert {

    public static void main(String[] args) {
//        int[][] a = {{1,2},{3,5},{6,7},{8,10},{12,16}};
        int[][] a = {{1,5}};
        int[] b = {2, 7};
        int[][] insert = new Insert().insert(a, b);
    }

    public int[][] insert(int[][] intervals, int[] newInterval) {
        if (intervals == null || intervals.length == 0) {
            return new int[][] {newInterval};
        }
        if (newInterval == null || newInterval.length == 0) {
            return intervals;
        }
        int a = intervals.length;
        List<int[]> list = new ArrayList<>(a);
        int p = newInterval[0];
        int q = newInterval[1];
        int flag = 1;
        int st = 0;
        int end = 0;

        int[][] res = new int[list.size()][2];
        for(int i = 0;i < list.size();++i){
            res[i] = list.get(i);
        }
        return res;
    }




}
